<%@ page import="com.zafu.dao.AccountBean" %>
<%@ page import="java.net.URLDecoder" %>
<%@ page import="com.zafu.entity.AccountInfo" %>
<%@ page import="com.zafu.entity.CartGoodsInfo" %>
<%@ page import="com.zafu.dao.CartGoodsBean" %><%--
  Created by IntelliJ IDEA.
  User: 86189
  Date: 2024/12/21
  Time: 20:19
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String image = request.getParameter("image");
    if(image != null && image.length() > 0)
        image = URLDecoder.decode(image, "UTF-8");

    String store = request.getParameter("store");
    if(store != null && store.length() > 0)
        store = URLDecoder.decode(store, "UTF-8");

    String name = request.getParameter("name");
    if(name != null && name.length() > 0)
        name = URLDecoder.decode(name, "UTF-8");

    // 处理 Double 类型的 price 参数
    Double price = null;
    String priceParam = request.getParameter("price");
    if (priceParam != null && priceParam.length() > 0) {
        try {
            price = Double.parseDouble(priceParam);
        } catch (NumberFormatException e) {
            // 如果转换失败，可以记录日志或抛出异常
            System.out.println("Invalid price: " + priceParam);
        }
    }

    String info = request.getParameter("info");
    if(info != null && info.length() > 0)
        info = URLDecoder.decode(info, "UTF-8");

    // 处理 Integer 类型的 count 参数
    Integer count = null;
    String countParam = request.getParameter("count");
    if (countParam != null && countParam.length() > 0) {
        try {
            count = Integer.parseInt(countParam);
        } catch (NumberFormatException e) {
            // 如果转换失败，可以记录日志或抛出异常
            System.out.println("Invalid count: " + countParam);
        }
    }

    Integer id = null;
    String idParam = request.getParameter("id");
    if (idParam != null && idParam.length() > 0) {
        try {
            id = Integer.parseInt(idParam);
        } catch (NumberFormatException e) {
            // 如果转换失败，可以记录日志或抛出异常
            System.out.println("Invalid id: " + idParam);
        }
    }

    CartGoodsInfo cartGoodsInfo = new CartGoodsInfo(image, store, price, name, info, count,id);
    //CartGoodsInfo cartGoodsInfo = new CartGoodsInfo("aa1", "重庆小面", 19.0, "重庆麻辣小面", "中辣", 1,5);
    CartGoodsBean bean = new CartGoodsBean();
    out.println("插入成功");
    bean.Add(cartGoodsInfo);
%>
